<form action="index.php" method="post" name="adminForm" enctype="multipart/form-data">

  <script type="text/javascript">
  jQuery(document).ready(
    function(){
        jQuery('#season_id').change();
    });
  </script>

  <table class="adminlist">
    <thead>
      <tr>
        <th width="20">
          <input type="checkbox" name="toggle" value="" onclick="checkAll(<?= count($this->stats); ?>);" />
        </th>
        <th class="title"><?= JHTML::_( 'grid.sort', 'Player', 'name', $this->lists['order_Dir'], $this->lists['order']); ?></th>
        <th width="15%"><?= JHTML::_( 'grid.sort', 'Schedule', 'schedule', $this->lists['order_Dir'], $this->lists['order']); ?></th>
        <th width="5%"><?= JHTML::_( 'grid.sort', 'Points', 'points', $this->lists['order_Dir'], $this->lists['order']); ?></th>
        <th width="5%"><?= JHTML::_( 'grid.sort', 'Field Goals', 'field_goals', $this->lists['order_Dir'], $this->lists['order']); ?></th>
        <th width="5%"><?= JHTML::_( 'grid.sort', 'Field Goal Attempts', 'field_goal_attempts', $this->lists['order_Dir'], $this->lists['order']); ?></th>
        <th width="5%"><?= JHTML::_( 'grid.sort', 'Three Points', 'three_points', $this->lists['order_Dir'], $this->lists['order']); ?></th>
        <th width="5%"><?= JHTML::_( 'grid.sort', 'Three Points Attempts', 'three_point_attempts', $this->lists['order_Dir'], $this->lists['order']); ?></th>
        <th width="5%"><?= JHTML::_( 'grid.sort', 'Free Throws', 'free_throws', $this->lists['order_Dir'], $this->lists['order']); ?></th>
        <th width="5%"><?= JHTML::_( 'grid.sort', 'Free Throw Attempts', 'free_throw_attemps', $this->lists['order_Dir'], $this->lists['order']); ?></th>
        <th width="5%"><?= JHTML::_( 'grid.sort', 'Off Rebounds', 'off_rebounds', $this->lists['order_Dir'], $this->lists['order']); ?></th>
        <th width="5%"><?= JHTML::_( 'grid.sort', 'Def Rebounds', 'def_rebounds', $this->lists['order_Dir'], $this->lists['order']); ?></th>
        <th width="5%"><?= JHTML::_( 'grid.sort', 'Assists', 'assists', $this->lists['order_Dir'], $this->lists['order']); ?></th>
        <th width="5%"><?= JHTML::_( 'grid.sort', 'Steals', 'steals', $this->lists['order_Dir'], $this->lists['order']); ?></th>
        <th width="5%"><?= JHTML::_( 'grid.sort', 'Blocks', 'blocks', $this->lists['order_Dir'], $this->lists['order']); ?></th>
        <th width="5%"><?= JHTML::_( 'grid.sort', 'Published', 'published', $this->lists['order_Dir'], $this->lists['order']); ?></th>
      </tr>
    </thead>
    <?php
      jimport('joomla.filter.output');
      for($i=0; $i< count($this->stats); $i++)
      {
        $stat       = &$this->stats[$i];
        $checked    = JHTML::_('grid.id', $i, $stat->id);
        $published    = JHTML::_('grid.published', $stat, $i);
        $link      = 'index.php?option=' . $option . '&task=edit&c=playergamestat&cid[]='. $stat->id;

        $schedule         = $stat->schedule;
        $person           = $stat->name;
        $points           = $stat->points;
        $field_goals      = $stat->field_goals;
        $field_goal_attempts = $stat->field_goal_attempts;
        $three_points     = $stat->three_points;
        $three_point_attempts= $stat->three_point_attempts;
        $free_throws      = $stat->free_throws;
        $free_throw_attempts = $stat->free_throw_attempts;
        $off_rebounds     = $stat->off_rebounds;
        $def_rebounds     = $stat->def_rebounds;
        $assists          = $stat->assists;
        $steals           = $stat->steals;
        $blocks           = $stat->blocks;

    ?>
      <tr>
        <td>
          <?= $checked; ?>
        </td>
        <td>
          <a href="<?= $link; ?>"><?= $person ?></a>
        </td>
        <td>
          <?= $schedule ?>
        </td>
        <td>
          <?= $points ?>
        </td>
        <td>
          <?= $field_goals ?>
        </td>
        <td>
          <?= $field_goal_attempts ?>
        </td>
        <td>
          <?= $three_points ?>
        </td>
        <td>
          <?= $three_point_attempts ?>
        </td>
        <td>
          <?= $free_throws ?>
        </td>
        <td>
          <?= $free_throw_attempts ?>
        </td>
        <td>
          <?= $off_rebounds ?>
        </td>
        <td>
          <?= $def_rebounds ?>
        </td>
        <td>
          <?= $assists ?>
        </td>
        <td>
          <?= $steals ?>
        </td>
        <td>
          <?= $blocks ?>
        </td>
        <td>
          <?= $published ?>
        </td>
      </tr>
    <?php
      }
    ?>
    <tr>
      <td colspan="16"><?= $this->pagination->getListFooter(); ?></td>
    </tr>
  </table>
  <fieldset>
    <legend>Export CSV</legend>

    <?$wks_link="onchange=\"ajx_request('playergamestat', 'ajx_get_weeks', 'season_id='+this.value , 'div_weeks');\""?>
    <div style="float:left">
      <?= JText::_('Season:')?><? $seasons = $this->seasons? $this->seasons : array(); ?>
      <?= JHTML::_('select.genericlist', $seasons, 'season_id', $wks_link, 'id', 'name', null); ?>
    </div>
    <div id='div_weeks' name='div_weeks' style="float:left"></div>
    <a href="#" onclick="javascript: submitbutton('export')" class="toolbar">Export to CSV</a>

  </fieldset>
  <fieldset>
    <legend>Import CSV</legend>
    <input type="file" name="file_upload" id="file_upload" />
    <a href="#" onclick="javascript: submitbutton('import')" class="toolbar">Import CSV</a>
  </fieldset>
  <input type="hidden" name="option" value="<?= JRequest::getVar( 'option' );?>"/>
  <input type="hidden" name="c" value="<?= JRequest::getVar('c', 'venue'); ?>" />
    <input type="hidden" name="task" value=""/>
    <input type="hidden" name="boxchecked" value="0"/>
  <input type="hidden" name="filter_order" value="<?php echo $this->lists['order']; ?>" />
  <input type="hidden" name="filter_order_Dir" value="<?php echo $this->lists['order_Dir']; ?>" />
</form>
